<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('news_model');
	}


	public function show(){
		$id = (int)$this->uri->segment(3);
		if(!$id) show_error('错误的操作');

		$data['p'] = $p = $this->news_model->get_news_byid($id);

		if(!$p) show_error('该新闻可能已经被删除');

		//最新动态
		$this->load->model('news_model');
		$data['news'] = $this->news_model->get_news(0,PAGENUM,true);

		//专业知识
		$this->load->model('know_model');
		$data['know'] = $this->know_model->get_know(0,PAGENUM,true);
		$this->load->view('news/show.tpl',$data);
		
	}

	public function more(){
		$start = $this->uri->segment(3,0);
		$data['news'] = $this->news_model->get_news($start,PAGENUM,true);
		$data['num'] = $this->news_model->get_news_num(true);

		//pagenation
		$this->load->library('pagination');
		$config['base_url'] = '/news/more/';
		$config['total_rows'] = $data['num'];
		$config['per_page'] = PAGENUM; 
		$config['full_tag_open'] = '<p class="page">';
		$config['full_tag_close'] = '</p>';
		$config['uri_segment'] = 3;
		$config['first_link'] = '首页';
		$config['last_link'] = '尾页';
		$config['cur_tag_open'] = '<b>';
		$config['cur_tag_close'] = '</b>';
		$config['next_link'] = '下一页';
		$config['prev_link'] = '上一页';
		$this->pagination->initialize($config); 
		$data['page'] = $this->pagination->create_links();

		$this->load->view('news/more.tpl',$data);
	}
}

/* End of file production.php */
/* Location: ./application/controllers/admin/production.php */